/**
 * 2
 *  
 * @Author : Ruoyu Wang
 * @DateTime : 24-10-17 下午4:12
 */

#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
    string s;
    cin >> s;
    unordered_map<char, int> map;
    for (char ch: s) {
        map[ch]++;
    }
    int tmp = 0x3f3f3f3f;
    int res = -1;
    for (int i = 0; i < s.size(); ++i) {
        if (tmp > map[s[i]]) {
            res = i;
            tmp = map[s[i]];
        }
    }
    cout << res;
    return 0;
}